package com.graduation.fms.mapper;

import com.graduation.fms.dao.Fk;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author MyBatisPlusAutoGenerator
 * @since 2021-05-22
 */
public interface FkMapper extends BaseMapper<Fk> {

    @Select("SELECT user.user_name as userName,user.name as name,user.telephone as telephone," +
            "user.email as email,fk.msg as msg,fk.create_time as createTime\n" +
            "FROM fk LEFT JOIN user on fk.user_id=user.user_id")
    @Results({
            @Result(property = "userName", column = "userName"),
            @Result(property = "name", column = "name"),
            @Result(property = "telephone", column = "telephone"),
            @Result(property = "email", column = "email"),
            @Result(property = "msg", column = "msg"),
            @Result(property = "createTime", column = "createTime")})
    List<Map<String, Object>> getFk();

    @Select("SELECT user.user_name as userName,user.name as name,user.telephone as telephone," +
            "user.email as email,fk.msg as msg,fk.create_time as createTime\n" +
            "FROM fk LEFT JOIN user on fk.user_id=user.user_id where user.user_name like #{key} or user.name like #{key}")
    @Results({
            @Result(property = "userName", column = "userName"),
            @Result(property = "name", column = "name"),
            @Result(property = "telephone", column = "telephone"),
            @Result(property = "email", column = "email"),
            @Result(property = "msg", column = "msg"),
            @Result(property = "createTime", column = "createTime")})
    List<Map<String, Object>> getFkByKey(@Param("key") String key);

}
